package com.example.sport.service.impl;

import com.example.sport.domain.AthleteEventResult;
import com.example.sport.domain.CollegeRankAndPoints;
import com.example.sport.domain.EventResult;
import com.example.sport.mapper.AthleteEventResultMapper;
import com.example.sport.mapper.EventResultMapper;
import com.example.sport.mapper.JudgeMapper;
import com.example.sport.service.JudgeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class JudgeServiceImpl implements JudgeService {

    @Autowired
    private JudgeMapper judgeMapper;

    @Override
    public List<CollegeRankAndPoints> getCollegeRankAndPointsByCollegeName(String collegeName) {
        return judgeMapper.getCollegeRankAndPointsByCollegeName(collegeName);
    }

    @Autowired
    private EventResultMapper eventResultMapper;

    @Override
    public void updateAthleteScore(EventResult eventResult) {

        EventResult newEventResult= new EventResult();
        newEventResult.setId(eventResult.getId());
        newEventResult.setScore(eventResult.getScore());
        newEventResult.setPoints(eventResult.getPoints());
        eventResultMapper.updateById(newEventResult);
    }

    @Override
    public int updateResult(EventResult eventResult) {
        return eventResultMapper.updateById(eventResult);
    }

    @Override
    public int addResult(EventResult eventResult) {
        return eventResultMapper.insert(eventResult);
    }



    @Autowired
    private AthleteEventResultMapper athleteEventResultMapper;

    @Override
    public AthleteEventResult getAthleteEventResultsById(String id) {
        return athleteEventResultMapper.getAthleteEventResultsById(id);
    }




}
